package com.leyou.item.client;

import com.leyou.item.dto.*;
import com.leyou.vo.PageResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.ArrayList;
import java.util.List;

@FeignClient("ly-item-service")
public interface ItemClient {

    /**
     * 根据id查询SpuDetail
     * @param id
     * @return
     */
    @GetMapping("/spu/detail")
    SpuDetailDTO querySpuDetailBySpu(@RequestParam("id") Long id);

    /**
     * 根据规格分组的gid、分类的cid、是否需要被搜索searching，查询规格参数param
     * @param gid
     * @param cid
     * @param searching
     * @return
     */
    @GetMapping("/spec/params")
    List<SpecParamDTO> querySpecParams(
            @RequestParam(value = "gid", required = false) Long gid,
            @RequestParam(value = "cid",required = false) Long cid,
            @RequestParam(value = "searching",required = false)Boolean searching
    );

    /**
     * 根据三级ids批量查询分类
     * @param ids
     * @return
     */
    @GetMapping("/category/list")
    List<CategoryDTO> queryCategoryByIds(@RequestParam("ids") List<Long> ids);

    /**
     * 根据spuId查询Sku
     * @param id
     * @return
     */
    @GetMapping("/sku/of/spu")
    List<SkuDTO> querySkuBySpu(@RequestParam("id") Long id);

    /**
     * 根据bid查询品牌
     *
     * @param bid
     * @return
     */
    @GetMapping("/brand/{bid}")
    BrandDTO queryBrandById(@PathVariable("bid") Long bid);

    /**
     * 分页查询商品
     * @param key
     * @param saleable
     * @param page
     * @param rows
     * @return
     */
    @GetMapping("/spu/page")
    PageResult<SpuDTO> querySpuByPage(
            @RequestParam(value = "key",required = false)String key,
            @RequestParam(value = "saleable",required = false)Boolean saleable,
            @RequestParam(value = "page",defaultValue = "1")Integer page,
            @RequestParam(value = "rows",defaultValue = "5")Integer rows
    );

    /**
     * 根据品牌ids批量查询品牌
     * @param ids
     * @return
     */
    @GetMapping("/brand/list")
    List<BrandDTO> queryBrandByIds(@RequestParam("ids") List<Long> ids);

    /**
     * 根据spu的id查询spu
     * @param id
     * @return
     */
    @GetMapping("/spu/{id}")
    SpuDTO querySpuById(@PathVariable("id") Long id);

    /**
     * 根据cid查询规格组及组内参数
     * @param id
     * @return
     */
    @GetMapping("/spec/of/category")
    List<SpecGroupDTO> querySpecsByCid(@RequestParam("id") Long id);
}
